package com.example.bzh.gamecat.httputils.societyutils;

import android.util.Log;

import com.example.bzh.gamecat.bean.AllSocietyBean;
import com.example.bzh.gamecat.bean.SocietyBean;
import com.example.bzh.gamecat.httputils.RetrofitHelper;
import com.example.bzh.gamecat.ui.society.ISocietyService;
import com.example.bzh.gamecat.ui.society.allsociety.IAllSocietyService;

import java.util.HashMap;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by MyPC on 2016/8/13.
 */
public class AllSocietyHttpUtil {

    private static AllSocietyHttpUtil instance;

    private AllSocietyHttpUtil(){
    }

    public static synchronized AllSocietyHttpUtil getInstance(){
        if (instance == null){
            instance = new AllSocietyHttpUtil();
        }
        return instance;
    }

    public interface HttpCallBack<T>{
        public void onSucess(T t);

        public void onFail();
    }

    public void getSociety(HashMap<String,String> params, final HttpCallBack<AllSocietyBean> recommendBeanHttpCallBack){
        Call<AllSocietyBean> beanCall = RetrofitHelper
                .getInstance()
                .createRetrofitService(IAllSocietyService.class)
                .getAllSocietyBean(params);
        beanCall.enqueue(new Callback<AllSocietyBean>() {
            @Override
            public void onResponse(Call<AllSocietyBean> call, Response<AllSocietyBean> response) {
//                Log.e("TAG","AAAA.........."+response.body().getData().getActiveList().size());
                recommendBeanHttpCallBack.onSucess(response.body());
            }

            @Override
            public void onFailure(Call<AllSocietyBean> call, Throwable t) {
                recommendBeanHttpCallBack.onFail();
            }
        });
    }
}
